package ua.kpi_java_training.zabrodskyi.module3;

/**
 * The user class for generation of the random data.
 * 
 * @author Maksym Zabrodskyi
 * @version 25-Jun-2013
 */
public class Random {

	/**
	 * Generates a random cell within environment.
	 * 
	 * @return cell within environment.
	 */
	public static Cell getCell() {
		int randomX = (int) (Math.random() * Settings.getWidth());
		int randomY = (int) (Math.random() * Settings.getHeight());
		return new Cell(randomX, randomY);
	}

	/**
	 * Generates a random variable of a step for movement from 1 to the maximum
	 * step.
	 * 
	 * @param maxStep
	 *            - The maximum step on which the animal can move.
	 * @return integer from 1 to maxStep.
	 */
	public static int getStep(int maxStep) {
		return (int) (Math.random() * maxStep + 1);
	}

	/**
	 * Generates a random direction of movement in environment from enumeration
	 * of directions.
	 * 
	 * @return random direction.
	 */
	public static Direction getDirection() {
		return Direction.values()[getIndex()];
	}

	/**
	 * Generates a random index of a direction from enumeration of directions.
	 * 
	 * @return integer - a direction index.
	 */
	private static int getIndex() {
		return (int) (Math.random() * Direction.values().length);
	}

}
